{#
    wazuh_doc_theme/layout.html
    ~~~~~~~~~~~~~~~~~

    Master layout template for Wazuh Documentation Sphinx theme.
#}

{# TEMPLATE VAR SETTINGS #}
{% set dash_separator = " &dash; " %}
{%- set url_root = pathto('', 1) %}
{% set script_files = script_files + ["_static/js/popper.min.js"] %}
{% set script_files = script_files + ["_static/js/bootstrap.min.js"] %}
{%- if url_root == '#' %}{% set url_root = '' %}{% endif %}
{%- if not embedded and docstitle %}
  {%- set titlesuffix = " &middot; "|safe + docstitle|e %}
{%- else %}
  {%- set titlesuffix = "" %}
{%- endif %}

{%- macro css() %}
  <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
  {% for cssfile in css_files %}
    <link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
  {% endfor %}
  <link rel='stylesheet' id='google-fonts-css'  href='https://fonts.googleapis.com/css?family=Montserrat:400,500|Open+Sans:400,700|Fira+Mono' type='text/css' media='all' />
{%- endmacro %}

{%- macro js() %}
  {% for scriptfile in script_files %}
    <script src="{{ pathto(scriptfile, 1) }}"></script>
  {% endfor %}
{%- endmacro %}

<!DOCTYPE html>
<html lang="{{ language }}">
{% block head %}
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta charset="UTF-8">
  <meta name="author" content="Wazuh" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  {{- metatags }}

  {% block htmltitle %}
    {%- if not parents[-1] %}
      <title>{{ title|striptags|e }}{{ titlesuffix }}</title>
    {%- else %}
      <title>{{ title|striptags|e }}{{ dash_separator }}{{ parents[-1].title|striptags|e }}{{ titlesuffix }}</title>
    {%- endif %}
  {%- endblock htmltitle %}

  {%- block css %}
    {{- css() }}
  {%- endblock css %}

  {%- block linktags %}
    {%- if hasdoc('about') %}
      <link rel="author" title="{{ _('About these documents') }}"
              href="{{ pathto('about') }}"/>
    {%- endif %}
    {%- if hasdoc('genindex') %}
      <link rel="index" title="{{ _('Index') }}" href="{{ pathto('genindex') }}"/>
    {%- endif %}
    {%- if hasdoc('search') %}
        <link rel="search" title="{{ _('Search') }}" href="{{ pathto('search') }}"/>
    {%- endif %}
    {%- if hasdoc('copyright') %}
        <link rel="copyright" title="{{ _('Copyright') }}" href="{{ pathto('copyright') }}"/>
    {%- endif %}
    <link rel="top" title="{{ docstitle|e }}" href="{{ pathto('index') }}"/>
    {%- if parents %}
        <link rel="up" title="{{ parents[-1].title|striptags|e }}" href="{{ parents[-1].link|e }}"/>
    {%- endif %}
    {%- if next %}
        <link rel="next" title="{{ next.title|striptags|e }}" href="{{ next.link|e }}"/>
    {%- endif %}
    {%- if prev %}
        <link rel="prev" title="{{ prev.title|striptags|e }}" href="{{ prev.link|e }}"/>
    {%- endif %}
  {%- endblock %}

  {# FAVICON  and canonical #}
  {%- if favicon %}
    <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
  {%- endif %}

  {# OPENSEARCH #}
  {% if not embedded %}
    {% if use_opensearch %}
      <link rel="search" type="application/opensearchdescription+xml" title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}" href="{{ pathto('_static/opensearch.xml', 1) }}"/>
    {% endif %}
  {% endif %}

  {# Google Analytics #}

  {% if production %}
  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-65317123-3', 'auto');
    ga('send', 'pageview');
  </script>
  {% endif %}

</head>
{%- endblock head %}
<body>
  {# Back to top #}
  <a id="btn-scroll" href="#" title="Back to top">
    <i class="fa fa-chevron-circle-up" aria-hidden="true"></i>
  </a>

  {% if pagename == 'index' %}
  <div id="page" class="index">
  {% elif pagename == 'not_found' %}
  <div id="page" class="page-404 not-indexed">
  {% elif pagename == 'search' or pagename == 'genindex' %}
  <div id="page" class="not-indexed">
  {% else %}
  <div id="page">
  {% endif %}

    {% include "header.html" %} {%- block header %}{% endblock header %}

    <section  class="container-fluid central-page-area">
      <div class="row">

        <div id="navbar" class="full-toctree-nav navbar-expand-lg navbar-light order-0 hidden">

          <div id="search-lg" class="title-bar-right col-lg-12 collapsed">
            {% include "searchbar.html" %}
          </div> <!-- // #search-lg -->

          <div id="navbar-globaltoc" class="side-scroll collapse navbar-collapse">
            <div id="globaltoc" class="globaltoc" role="navigation" aria-label="main navigation">

              <nav>
                {% block menu %}
                {% set toctree = toctree(maxdepth=theme_globaltoc_depth|toint, collapse=theme_collapse_navigation, includehidden=theme_globaltoc_includehidden|tobool) %}
                {% if toctree %}
                {{ toctree }}
                {% endif %}
                {% endblock %}
              </nav>

              <aside class="help col-12">
                <a class="btn-help" title="Open source community" href="https://wazuh.com/community/">Open source community</a>
                <a class="btn-help" title="Professional services" href="https://wazuh.com/professional-services/">Professional services</a>
              </aside>

            </div>
          </div>

        </div>

        <div id="main-content" class="order-1">
          <div id="rst-content">

          {% if pagename != 'index' and pagename != 'not_found' and pagename != 'search' and pagename != 'genindex' %}
          <div class="edit-repo-wrapper">
            {% include "editrepo.html" %}
          </div>
          <div class="breadcrumbs-wrapper">
            {% include "breadcrumbs.html" %}
          </div>
          {% endif %}

          {# Main content #}
          <main role="main">
            {% block body %} {% endblock %}
          </main>

          {% if pagename != 'index' %}
            {% include "navigation.html" %}
          {% endif %}

          </div>
          <footer>
            {{copyright}}
          </footer>

        </div>

      </div>

    </section>

  </div> <!-- // #page -->
  {# Footer's scripts #}
  {%- block footer_js %}
    {% if not embedded %}
    {% if sphinx_version >= "1.8.0" %}
      <script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
      {%- for scriptfile in script_files %}
        {{ js_tag(scriptfile) }}
      {%- endfor %}
    {% else %}
      <script type="text/javascript">
          var DOCUMENTATION_OPTIONS = {
              URL_ROOT:'{{ url_root }}',
              VERSION:'{{ release|e }}',
              LANGUAGE:'{{ language }}',
              COLLAPSE_INDEX:false,
              FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
              HAS_SOURCE:  {{ has_source|lower }},
              SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
          };
      </script>
      {{- js() }}
    {% endif %}
  {% endif %}
  {%- endblock footer_js %}

</body>
</html>
